/*
 *  Copyright 2011 Gedare Bloom.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 */

#ifndef _LIBCPU_MMU_SUPPORT_H_
#define _LIBCPU_MMU_SUPPORT_H_

#ifdef __cplusplus
extern "C" {
#endif

#define SPARC64_TRAP_FAST_INSTRUCTION_ACCESS_MMU_MISS 0x64
#define SPARC64_TRAP_FAST_DATA_ACCESS_MMU_MISS    0x68
#define SPARC64_TRAP_FAST_DATA_ACCESS_PROTECTION    0x6c

#define SPARC64_PAGE_SIZE (1<<13) /* 8K */

#include "arch/mm/tlb.h"
#include <rtems/rtems/types.h>
extern uintptr_t sparc64_physmem_base;
#define p_to_f(_p) (((uintptr_t)_p)+sparc64_physmem_base)

void sparc64_dtlb_insert(uintptr_t page, uintptr_t frame, int size, 
    uint16_t context, bool writable, bool cacheable, bool locked);
void sparc64_itlb_insert(uintptr_t page, uintptr_t frame, int size, 
    uint16_t context, bool cacheable, bool locked);
void sparc64_tlb_invalidate_pages(uintptr_t first_page, size_t num_pages);

void sparc64_fast_instruction_access_mmu_miss_handler(
    uint64_t vector_number,
    CPU_Interrupt_frame *istate
);
void sparc64_fast_data_access_mmu_miss_handler(
    uint64_t vector_number,
    CPU_Interrupt_frame *istate
);
void sparc64_fast_data_access_protection_handler(
    uint64_t vector_number,
    CPU_Interrupt_frame *istate
);

void sparc64_mmu_initialize(void); 
void sparc64_tlb_print(void); 

#ifdef __cplusplus
}
#endif

#endif
